package manager
{
	import flash.display.BitmapData;
	import flash.system.ApplicationDomain;
	import texture.BitmapEx;

	public class ResourceMgr
	{
		public function ResourceMgr()
		{
		}
		
		
		public static function getResList():Array
		{
			var arr:Array = new Array();
			
			var xml:XML = XmlMgr.inst.getXML("resourceList.xml");
			
			var xmllist:XMLList = xml.children();
			
			for (var i:int = 0; i < xmllist.length(); i++) 
			{
				arr.push(xmllist[i].@url);
			}
			
			return arr;
		}
		
		public static function getClass(strKey:String):Class
		{
			var cl:Class = null;
			try{
				cl = ApplicationDomain.currentDomain.getDefinition(strKey) as Class;
			}catch(e:Error){
				trace(strKey + " 域取资源不存在");
				throw e;
			}
			return cl;
		}
		
		public static function getBitmapData(strKey:String):BitmapData
		{
			var cl:Class = getClass(strKey);
			if(!cl)
				return null;
			return new cl() as BitmapData;
		}
		
		public static function getBitmapEx(strKey:String):BitmapEx
		{
			return new BitmapEx(getBitmapData(strKey));
		}
	}
}